<template>
    <div style="height:100%;">
        <loading></loading>
        <transition name="slide-fade">
            <keep-alive :include="getKeepAliveList">
                <router-view></router-view>
            </keep-alive>
        </transition>
    </div>
</template>

<script>
import loading from '@/repeatComponents/loading';
import { localSave, setToken } from '@/utils/utils';
import { mapState } from 'vuex';
import Watermark from '@/libs/watermark.js';
export default {
    name: 'App',
    data() {
        return {
        };
    },
    components: {
        loading
    },
    computed: {
        getKeepAliveList() {
            return this.$store.state.config.keepAliveList;
        }
    },
    mounted() {
    },
    methods: {
        ...mapState(['locale']),
        getTabelValueReset(val) {
            var lang = this.$i18n.locale;
            if ((val && val !== 'null' && val !== 'undefined')) {
                let newVal = val.indexOf('CN') > -1 ? 'cn' : val.indexOf('EN') > -1 ? 'en' : 'hk';
                this.$i18n.locale = newVal;
                localSave('locale', newVal);
                localSave('globalLang', newVal);
                window.localStorage.setItem('globalLang', newVal);
            }
        },
        getToken(val) {
            // setToken(val);
            localSave('token', val);
        },
        getUsrId(val) {
            Watermark.out(); // 清除用户水印
            setTimeout(() => {
                Watermark.set(val);
            }, 500);
            localSave('usrSteUsrId', val);
        }
    },
    watch: {
        '$route.query.examIframeLang': 'getTabelValueReset',
        '$route.query.examIframeToken': 'getToken',
        '$route.query.examIframeUsrId': 'getUsrId'
    }
};
</script>

<style lang="less">
    @import "../static/commonLess.less";
    /*.slide-fade-enter-active {
        transition: all .6s ease;
    }
    .slide-fade-leave-active {
        //transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
        //transform: translateX(100%);
    }
    .slide-fade-enter, .slide-fade-leave-to
        !* .slide-fade-leave-active for below version 2.1.8 *! {
        transform: translateX(100%);
        //opacity: 0;
    }*/
</style>
